package cn.yuanqiao.activiti.listener;

import cn.yuanqiao.archive.Identify.service.DestroyService;
import cn.yuanqiao.common.exception.activiti.ArchiveProcessException;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName: WritsArchiveCopyListener
 * @Description: 类的描述
 * @author: lihuahua
 * @date: 2023/6/5 19:24
 * @Blog: huahuacoco.top
 */

@Component("ArchiveDestroyAgreeListener")
public class ArchiveDestroyAgreeListener implements ExecutionListener {

    @Autowired
    private DestroyService destroyService;

    @Override
    public void notify(DelegateExecution execution) {
        Object processVariables = execution.getVariable("processVariables");

        if (processVariables == null){
            throw new ArchiveProcessException("销毁数据Id不能为空");
        }
        String destroyId = String.valueOf(((Map<String,Object>)processVariables).get("destroyId"));

        System.out.println("同意销毁，调用接口");
        destroyService.endDestroy(Long.valueOf(destroyId));
    }

}
